import java.io.*;

/**
 * @author Macrydy
 * @date 2022/5/12
 *
 * 字节缓冲流
 *
 */
public class BuffStreamDemo {
    public static void main(String[] args) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("F:\\FileDemo\\b.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File("F:\\FileDemo\\b-copy.txt")));

        //一个一个读取
        int i;
        while ((i = bis.read()) != -1) {
            System.out.println(i);
        }

        //拷贝 一个数组读写
        //字节缓冲流默认大小为8m
        byte[] bytes = new byte[1024];
        int len;
        while ((len = bis.read(bytes)) != -1) {
            bos.write(bytes,0,len);
        }


        bis.close();
        bos.close();
    }

}
